package com.ctshk.rpc.tour.mapper;

import java.util.List;

import com.ctshk.rpc.tour.entity.SeriesTripScheduleChannelOfflineSelfCustom;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ctshk.common.service.mapper.CtsBaseMapper;
import com.ctshk.rpc.tour.base.CustomBaseMapper;
import com.ctshk.rpc.tour.entity.SeriesTripScheduleChannelOfflineAgentCustom;

/**
 * <p>
 * 团期线下代理商自定义权限 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-28
 */
public interface SeriesTripScheduleChannelOfflineAgentCustomMapper extends CustomBaseMapper<SeriesTripScheduleChannelOfflineAgentCustom>, CtsBaseMapper<SeriesTripScheduleChannelOfflineAgentCustom> {

	/**
	 * 查询团期的代理商ID
	 * @param scheduleId
	 * @return
	 */
	@Select("select t.agent_id from t_series_trip_schedule_channel_offline_agent_custom t where t.schedule_id = #{scheduleId} and t.is_deleted = 0")
	List<Long> queryAgentIdListBySchedule(Long scheduleId);

	/**
	 * 查询加幅
	 * @param userId
	 * @param scheduleId
	 * @return
	 */
	@Select("SELECT *\n" +
			"FROM t_series_trip_schedule_channel_offline_agent_custom\n" +
			"WHERE schedule_id = #{schedule_id} AND is_deleted = 0 AND (check_type = 2 OR (check_type = 3 AND agent_id = #{user_id})) LIMIT 1")
    SeriesTripScheduleChannelOfflineSelfCustom queryByCondition(@Param("user_id") Long userId, @Param("schedule_id")Long scheduleId);
}
